package com.xbb.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xbb.entity.Teacher;
import com.xbb.entity.dto.TeacherDto;
import com.xbb.service.TeacherService;
import com.xbb.util.Result;

@RestController
public class TeacherController {

	@Autowired
	private TeacherService teacherService;
	
	@RequestMapping("/getTeaList")
	public Object getTeaList(TeacherDto teacherDto,ModelMap map) {
		List<TeacherDto> list = teacherService.getTeas(teacherDto);
		teacherDto.setLimit(null);
		teacherDto.setPage(null);
		List<TeacherDto> list2 = teacherService.getTeas(teacherDto);
		return new Result(0,"",list2.size(),list);
	}
	
	@RequestMapping("/addTea")
	public Object addTea(Teacher teacher) {
		if(teacherService.addTea(teacher)) {
			return new Result(0,"添加成功");
		}else {
			return new Result(1,"添加失败");
		}
	}
	
	
	@RequestMapping("/updateTea")
	public Object updateTea(Teacher teacher) {
		if(teacherService.updateTea(teacher)) {
			return new Result(0,"修改成功");
		}else {
			return new Result(1,"修改失败");
		}
	}
	
	
	@RequestMapping("/delTea")
	public Object delTea(int tid) {
		if(teacherService.delTea(tid)) {
			return new Result(0,"删除成功");
		}else {
			return new Result(1,"删除失败");
		}
	}
}
